package com.film.admincontroller;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.film.domain.Director;
import com.film.service.DirectorService;
import com.film.service.impl.DirectorServiceImpl;

/**
 * Servlet implementation class UpdateDirectorServlet
 */
@WebServlet("/updateDidrector.do")
public class UpdateDirectorServlet extends HttpServlet {
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		req.setCharacterEncoding("utf-8");
		DirectorService ser = new DirectorServiceImpl();
		Integer dirId=Integer.parseInt(req.getParameter("dirId"));
		String dirname=	req.getParameter("dirname");
		String dirforeignName=req.getParameter("dirforeignName");
		String dirnickName=req.getParameter("dirnickName");
		String dirbirth=req.getParameter("dirbirth");
		String dirheight=req.getParameter("dirheight");
		String dirsex=req.getParameter("dirsex");
		String dirnationality=req.getParameter("dirnationality");
		String dirbirthPlace=req.getParameter("dirbirthPlace");
		String dirstar=req.getParameter("dirstar");
		String dirintroduce=req.getParameter("dirintroduce");
		String dirimg=req.getParameter("dirimg");
		Director director = new Director(dirId,dirname,dirforeignName,dirnickName,dirbirth,dirheight,dirsex,dirnationality,dirbirthPlace,dirstar,dirintroduce);
		ser.updateDirector(director);
		HttpSession session = req.getSession();
		session.setAttribute("director", ser.selectDirector());
		resp.sendRedirect("/film/director.do"); 
		
	}


}
